<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserFreeCallTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_free_call_log', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->tinyInteger('free_minutes')->default(0)->comment('免费通话时长');
            $table->tinyInteger('used_minutes')->default(0)->comment('使用的通话时长');
            $table->integer('used_at')->default(0)->comment('被使用的时间');
            $table->tinyInteger('from')->default(0)->comment('获取来源');
            $table->integer('pay_order_id')->default(0)->comment('绑定充值订单ID');
            $table->integer('call_id')->default(0)->comment('使用的话单ID');
            $table->tinyInteger('call_type')->default(-1)->comment('使用的话单类型');
            $table->tinyInteger('status')->default(0)->comment('0-未使用，1-已使用，-1-已失效');
            $table->timestamps();
            $table->index('user_id', 'user_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_free_call');
    }
}
